package com.muyu.danmo.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoPersonalPictures;
import com.muyu.danmo.service.IDanmoPersonalPicturesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人信息作品图片集Controller
 *
 * @author yangle
 * @date 2024-09-21
 */
@RestController
@RequestMapping("/pictures")
public class DanmoPersonalPicturesController extends BaseController
{
    @Autowired
    private IDanmoPersonalPicturesService danmoPersonalPicturesService;

    /**
     * 查询个人信息作品图片集列表
     */
//    @RequiresPermissions("system:pictures:list")
    @GetMapping("/list")
    public Result list(DanmoPersonalPictures danmoPersonalPictures)
    {
        PageHelper.startPage(danmoPersonalPictures.getPageNum(),danmoPersonalPictures.getPageSize());
        List<DanmoPersonalPictures> list = danmoPersonalPicturesService.selectDanmoPersonalPicturesList(danmoPersonalPictures);
        PageInfo<DanmoPersonalPictures> danmoPersonalPicturesPageInfo = new PageInfo<>(list);
        return Result.success(danmoPersonalPicturesPageInfo);
    }

    /**
     * 导出个人信息作品图片集列表
     */
//    @RequiresPermissions("system:pictures:export")
    @Log(title = "个人信息作品图片集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoPersonalPictures danmoPersonalPictures)
    {
        List<DanmoPersonalPictures> list = danmoPersonalPicturesService.selectDanmoPersonalPicturesList(danmoPersonalPictures);
        ExcelUtil<DanmoPersonalPictures> util = new ExcelUtil<DanmoPersonalPictures>(DanmoPersonalPictures.class);
        util.exportExcel(response, list, "个人信息作品图片集数据");
    }

    /**
     * 获取个人信息作品图片集详细信息
     */
//    @RequiresPermissions("system:pictures:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {

        return success(danmoPersonalPicturesService.selectDanmoPersonalPicturesById(id));
    }

    /**
     * 新增个人信息作品图片集
     */
//    @RequiresPermissions("system:pictures:add")
    @Log(title = "个人信息作品图片集", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoPersonalPictures danmoPersonalPictures)
    {
        return toAjax(danmoPersonalPicturesService.insertDanmoPersonalPictures(danmoPersonalPictures));
    }

    /**
     * 修改个人信息作品图片集
     */
//    @RequiresPermissions("system:pictures:edit")
    @Log(title = "个人信息作品图片集", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoPersonalPictures danmoPersonalPictures)
    {
        return toAjax(danmoPersonalPicturesService.updateDanmoPersonalPictures(danmoPersonalPictures));
    }

    /**
     * 删除个人信息作品图片集
     */
//    @RequiresPermissions("system:pictures:remove")
    @Log(title = "个人信息作品图片集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoPersonalPicturesService.deleteDanmoPersonalPicturesByIds(ids));
    }


    /**
     * 官网查询作品集
     */
    @PostMapping("/inquireList")
    public Result inquireList(@RequestBody DanmoPersonalPictures danmoPersonalPictures)
    {
        PageHelper.startPage(danmoPersonalPictures.getPageNum(),danmoPersonalPictures.getPageSize());
        List<DanmoPersonalPictures> list = danmoPersonalPicturesService.selectinquireList(danmoPersonalPictures);
        PageInfo<DanmoPersonalPictures> danmoPersonalPicturesPageInfo = new PageInfo<>(list);
        return Result.success(danmoPersonalPicturesPageInfo);
    }

}
